<?php

class DocAction extends CommonAction {
	
    public function index(){

    	$this->assign("docs", M('Doc')->select());
    	$this->display();

    }
    
    public function addPicDocPage()
    {
    	# code...
    	$this->display();
    }

    public function addPicDoc()
    {
    	# code...

    	$db_doc = M('Doc');
		if($db_doc->create()){
			if($db_doc->add()){
				$this->ajaxReturn(array('status' => 1, 'info' => '新增成功！', 'data' => null, 'jumpUrl' => U('Doc/index') ));
			}else{
				$this->ajaxReturn(array('status' => 0, 'info' => '新增失败', 'data' => null, 'jumpUrl' => null ));
			}
		}
    }

    public function updatePicDoc()
    {
    	# code...
    	$db_doc = M('Doc');
    	if($db_doc->create()){
    		if($db_doc->save()){
				$this->ajaxReturn(array('status' => 1, 'info' => '更新成功！', 'data' => null, 'jumpUrl' => U('Doc/index') ));
			}else{
				$this->ajaxReturn(array('status' => 0, 'info' => '更新失败', 'data' => null, 'jumpUrl' => null ));
			}
    	}
    }

    public function delPicDoc()
    {
    	# code...
    	$id = I("id", -1);
    	if(M("Doc")->delete($id)){
			$this->ajaxReturn(array('status' => 1, 'info' => '删除成功', 'data' => null, 'jumpUrl' => U('Doc/index') ));
    	}else{
    		$this->ajaxReturn(array('status' => 0, 'info' => '删除失败', 'data' => null, 'jumpUrl' => null ));
    	}
    }

}

?>